package ar.edu.utn.frsf.cidisi.ginet.diagram.agim.graphicalextensions.figures;

import org.eclipse.draw2d.Ellipse;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle;
import org.pnml.tools.epnk.diagram.edit.parts.RefPlaceEditPart.RefPlaceFigure;
import org.pnml.tools.epnk.gmf.extensions.graphics.IUpdateableFigure;
import org.pnml.tools.epnk.gmf.extensions.graphics.figures.PlaceFigure;
import org.pnml.tools.epnk.pnmlcoremodel.RefPlace;

/** 
 *
 * 
 * @generated NOT
 * @author jmr
 *
 */
public class RefPlaceAgimFigure extends Ellipse implements IUpdateableFigure{

	private RefPlace refPlace;
	
	public RefPlaceAgimFigure(RefPlace refPlace) {
		this.refPlace = refPlace;
	}

	@Override
	public void update() {
		this.repaint();
	}
	
	@Override
	protected void fillShape(Graphics graphics) {
		graphics.setLineStyle(Graphics.LINE_DASH);
		super.fillShape(graphics);
		if (refPlace instanceof ar.edu.utn.frsf.cidisi.ginet.abstractginet.RefPlace ){
			
			if (((ar.edu.utn.frsf.cidisi.ginet.abstractginet.RefPlace)refPlace).getParallelCardinality() != null 
					&& !((ar.edu.utn.frsf.cidisi.ginet.abstractginet.RefPlace)refPlace).getParallelCardinality().equals("")
					&& !((ar.edu.utn.frsf.cidisi.ginet.abstractginet.RefPlace)refPlace).getParallelCardinality().equals("1")) {
				
//				int card = Integer.valueOf(((ar.edu.utn.frsf.cidisi.ginet.Place)place).getParallelCardinality()).intValue();
//				
//				if (card > 1){
				
					// First, get the location and dimension of the place as a rectangle
					Rectangle rectangle = this.getClientArea();
					graphics.setLineStyle(Graphics.LINE_DASH);
					graphics.drawOval(rectangle.x+5, rectangle.y+5, 
							rectangle.width-10, rectangle.height-10);
//				}
			
			}
		}
	}

}
